Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appium-logger

Package Overview
Dependencies
Maintainers
7
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appium-logger

Logging utility for appium

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
205
increased by32.26%
Maintainers
7
Weekly downloads
 
Created
Source

appium-logger

NPM version Downloads Dependency Status devDependency Status

Build Status Coverage Status

Basic logger defaulting to npmlog with special consideration for running tests (doesn't output logs when run with _TESTING=1 in the env).

Logging levels

There are a number of levels, exposed as methods on the log object, at which logging can be made. The built-in ones correspond to those of npmlog, and are: silly, verbose, info, http, warn, and error. In addition there is a debug level.

The default threshhold level is verbose.

The logged output, by default, will be level prefix message. So

import { getLogger } from 'appium-logger';
let log = getLogger('mymodule');
log.warn('a warning');`

Will produce

warn mymodule a warning

Environment variables

There are two environment variable flags that affect the way appium-logger works.

_TESTING

  • _TESTING=1 stops output of logs when set to 1.

_FORCE_LOGS

  • This flag, when set to 1, reverses the _TESTING

Usage

log.level

  • get and set the threshhold level at which to display the logs. Any logs at or above this level will be displayed. The special level silent will prevent anything from being displayed ever. See npmlog#level.

log[level](message)

  • logs to level
    import { getLogger } from 'appium-logger';
    let log = getLogger('mymodule');
    
    log.info('hi!');
    // => info mymodule hi!
    

log.unwrap()

  • retrieves the underlying npmlog object, in order to manage how logging is done at a low level (e.g., changing output streams, retrieving an array of messages, adding log levels, etc.).

    import { getLogger } from 'appium-logger';
    let log = getLogger('mymodule');
    
    log.info('hi!');
    
    let npmlogger = log.unwrap();
    
    // any `npmlog` methods
    let logs = npmlogger.record;
    // logs === [ { id: 0, level: 'info', prefix: 'mymodule', message: 'hi!', messageRaw: [ 'hi!' ] }]
    

log.errorAndThrow(error)

  • logs the error passed in, at error level, and then throws the error. If the error passed in is not an instance of Error (either directly, or a subclass of Error) it will be wrapped in a generic Error object.

    import { getLogger } from 'appium-logger';
    let log = getLogger('mymodule');
    
    // previously there would be two lines
    log.error('This is an error');
    throw new Error('This is an error');
    
    // now is compacted
    log.errorAndThrow('This is an error');
    

Keywords

FAQs

Package last updated on 25 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc